package com.xh.bussiness.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.system.bean.request.StudentCallRequest;
import com.xh.bussiness.system.dao.StudentCallMapper;
import com.xh.bussiness.system.model.StudentCall;
import com.xh.bussiness.system.service.IStudentCallService;
import com.xh.core.bean.XhPage;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 学生回访通讯录 服务实现类
 * </p>
 *
 * @author JQM
 * @since 2019-12-03
 */
@Service
public class StudentCallServiceImpl extends BaseServiceImpl<StudentCallMapper, StudentCall> implements IStudentCallService {
    @Override
    public XhPage queryStudentCallPage(XhPage page, StudentCallRequest bean) {
        QueryWrapper qw=new QueryWrapper<StudentCall>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public List queryStudentCall(StudentCallRequest bean) {
        QueryWrapper qw=new QueryWrapper<StudentCall>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }


    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(StudentCallRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        return qw;
    }
}
